﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
    public partial class Location
    {
        partial void Location_Created()
        {
            // sets boolean fields to true
            this.IsInvoiceAddress = true;
            this.IsPaymentAddress = true;
            this.IsShipAddress = true;
            this.IsActive = true;
        }
     
        // no fire if the drobdownlist changed -> bug or wrong event
        partial void Country_Changed()
        {
            //set the language if empty
            if (this.Country != null & this.Language == null)
            {
                this.Language = this.Country.Language;
            }
        }

        partial void Account_Changed()
        {
            // if the name is not set than insert the full Account Name as default 
            if (!string.IsNullOrEmpty(this.Account.FullName))
            {
                this.Name = this.Account.FullName;
            }
        }
    }
}
